package com.zyk.scaffold.oauth.domain;

import com.zyk.scaffold.oauth.framework.domain.UserDetails;
import com.zyk.scaffold.user.dto.TenantUserInfoDTO;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;


public class LocalTenantUserDetails implements UserDetails {
    private static final long serialVersionUID = 1L;
    private Long id;
    private String account;
    private String tenantCode;
    private String tenantName;
    private String name;
    private String phone;
    private String email;
    private String password;
    private Boolean enable;
    private LocalDateTime createTime;
    private List<String> authorities;
    private List<Map<String, Object>> menuApis;
    private List<Map<String, Object>> menuFunctions;
    public LocalTenantUserDetails(TenantUserInfoDTO tenantUserInfoDTO){
        this.id = tenantUserInfoDTO.getId();
        this.account = tenantUserInfoDTO.getAccount();
        this.name = tenantUserInfoDTO.getName();
        this.phone = tenantUserInfoDTO.getPhone();
        this.email = tenantUserInfoDTO.getEmail();
        this.password = tenantUserInfoDTO.getPassword();
        this.enable = tenantUserInfoDTO.getEnable();
        this.createTime = tenantUserInfoDTO.getCreateTime();
        this.authorities = tenantUserInfoDTO.getRoles();
        this.menuApis = tenantUserInfoDTO.getMenuApis();
        this.tenantCode = tenantUserInfoDTO.getTenantCode();
        this.tenantName = tenantUserInfoDTO.getTenantName();
        this.menuFunctions = tenantUserInfoDTO.getMenuFunctions();
    }

    @Override
    public List<String> getAuthorities() {
        return this.authorities;
    }

    @Override
    public String getPassword() {
        return this.password;
    }

    @Override
    public String getAccount() {
        return this.account;
    }

    @Override
    public boolean isEnabled() {
        return this.enable == null ? false : this.enable;
    }

    public Long getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public String getPhone() {
        return phone;
    }

    public String getEmail() {
        return email;
    }

    public LocalDateTime getCreateTime() {
        return createTime;
    }

    public List<Map<String, Object>> getMenuApis() {
        return menuApis;
    }

    public String getTenantCode() {
        return tenantCode;
    }

    public String getTenantName() {
        return tenantName;
    }

    public List<Map<String, Object>> getMenuFunctions() {
        return menuFunctions;
    }
}
